package com.higgins.lawapp.client.settings.components;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;

public class DataSourceLabelFields extends DataSourceComponent	{
	final Label label = new Label();
    final TextBox field = new TextBox();
    final ListBox list = new ListBox();
    
    public DataSourceLabelFields(String label, Integer number)	{
    	instantiate();
    	field.setText(label);
    	list.setItemSelected(number -1, true);
    }
    
	public DataSourceLabelFields()	{
		instantiate();
	}
	public void instantiate()	{
		this.setComponentType("Label");
	    field.setTitle("Label");
	    label.setText("Label");
	    list.addItem("1");
	    list.addItem("2");
	    list.addItem("3");
	    list.addItem("4");
	    list.addItem("5");
	    list.addItem("6");
	    list.addItem("7");
	    field.setText("");
	    add(label);
	    add(field);
	    add(list);
	    setWidgetLeftWidth(label, 0, Unit.PCT, 33, Unit.PCT);
	    setWidgetLeftWidth(field, 33, Unit.PCT, 33, Unit.PCT);
	    setWidgetRightWidth(list, 1, Unit.PCT, 33, Unit.PCT);
	}
	
	public String getLabel()	{
		return field.getText();
	}
	public Integer getNumber()	{
		int selectedIndex = list.getSelectedIndex();
		int itemCount = list.getItemCount();
		String firstItem = list.getItemText(0);
		
		if (list.getItemText(list.getSelectedIndex()).equals("0"))
			return 0;
		if (list.getItemText(list.getSelectedIndex()).equals("1"))
			return 1;
		if (list.getItemText(list.getSelectedIndex()).equals("2"))
			return 2;
		if (list.getItemText(list.getSelectedIndex()).equals("3"))
			return 3;
		if (list.getItemText(list.getSelectedIndex()).equals("4"))
			return 4;
		if (list.getItemText(list.getSelectedIndex()).equals("5"))
			return 5;
		if (list.getItemText(list.getSelectedIndex()).equals("6"))
			return 6;
		if (list.getItemText(list.getSelectedIndex()).equals("7"))
			return 7;
		return 0;
	}
}
